/*************************************************
Author: will
Date: 8/24/2012
Description:
Notes: 
*************************************************/

#ifndef __CBattleActionCtrl_h__
#define __CBattleActionCtrl_h__

#include "commclass.h"

class CBattleAction
{
public:
    enum BATTLE_ACTION_ID
    {
        ACTION_GET_TURN,   //开始行动
        ACTION_ROLE_DEAD,  //角色死亡
    };

public:
    CBattleAction() 
    {
    }

    virtual ~CBattleAction() 
    {
    }

    CBattleAction& operator=(const CBattleAction& stAction)
    {
        _iActionID = stAction._iActionID;
        _iA = stAction._iA;
        _iB = stAction._iB;

        return *this;
    }

    int Do();
    
    void DumpActionInfo();

public:
    int _iActionID;
    int _iA;
    int _iB;
};

class CBattleActionCtrl
{
public:
    CBattleActionCtrl() 
        : _iActionBeginPos(0), _iActionEndPos(0)
    {
    }

    virtual ~CBattleActionCtrl() {}

    int GetActionSize() const;
        
    bool IsFull() const
    {
        return GetActionSize() >= MAX_BATTLE_ACTION_COUNT - 1;
    }

    bool IsEmpty() const
    {
        return _iActionBeginPos == _iActionEndPos;
    }

    int AddAction(CBattleAction& stBattleAction);           //依次添加
    int GetAction(CBattleAction& stBattleAction);           //依次读取
    int PushAction(CBattleAction& stBattleAction);          //在顶部添加，压栈
    int PopAction(CBattleAction& stBattleAction);           //读顶部，出栈
    void DumpActionCtrlInfo();

private:
    int _iActionBeginPos;
    int _iActionEndPos;        //_iActionEndPos所指位置必定为空，所以实际可存储长度是MAX_BATTLE_ACTION_COUNT - 1
    CBattleAction _astActions[MAX_BATTLE_ACTION_COUNT];
};

#endif // __CBattleActionCtrl_h__

